﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbUnitsFormatter : OdUnitsFormatter
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbUnitsFormatter(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbUnitsFormatter_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbUnitsFormatter obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbUnitsFormatter()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbUnitsFormatter(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbUnitsFormatter cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbUnitsFormatter_cast(OdRxObject.getCPtr(pObj));
			OdDbUnitsFormatter result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbUnitsFormatter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbUnitsFormatter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbUnitsFormatter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbUnitsFormatter_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbUnitsFormatter_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbUnitsFormatter_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdDbUnitsFormatter createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbUnitsFormatter_createObject();
			OdDbUnitsFormatter result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbUnitsFormatter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbUnitsFormatter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbUnitsFormatter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static string formatColor(OdCmColor value)
		{
			string result = TD_DbPINVOKE.OdDbUnitsFormatter_formatColor(OdCmColor.getCPtr(value));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdCmColor unformatColor(string arg0)
		{
			OdCmColor result = new OdCmColor(TD_DbPINVOKE.OdDbUnitsFormatter_unformatColor(arg0), true);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double toUserAngle(double wcsAngle)
		{
			double result = TD_DbPINVOKE.OdDbUnitsFormatter_toUserAngle(this.swigCPtr, wcsAngle);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual double fromUserAngle(double ucsAngle)
		{
			double result = TD_DbPINVOKE.OdDbUnitsFormatter_fromUserAngle(this.swigCPtr, ucsAngle);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual string formatPoint(OdGePoint3d value)
		{
			string result = TD_DbPINVOKE.OdDbUnitsFormatter_formatPoint(this.swigCPtr, OdGePoint3d.getCPtr(value));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGePoint3d unformatPoint(string arg0)
		{
			OdGePoint3d result = new OdGePoint3d(TD_DbPINVOKE.OdDbUnitsFormatter_unformatPoint(this.swigCPtr, arg0), true);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGePoint3d toUCS(OdGePoint3d wcsPt)
		{
			OdGePoint3d result = new OdGePoint3d(TD_DbPINVOKE.OdDbUnitsFormatter_toUCS(this.swigCPtr, OdGePoint3d.getCPtr(wcsPt)), true);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGePoint3d fromUCS(OdGePoint3d ucsPt)
		{
			OdGePoint3d result = new OdGePoint3d(TD_DbPINVOKE.OdDbUnitsFormatter_fromUCS(this.swigCPtr, OdGePoint3d.getCPtr(ucsPt)), true);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
